package icu.cqcai.xinsi.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 聊天消息实体类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ChatMessage {
    
    /** 消息ID */
    private Long id;
    
    /** 会话ID */
    private Long sessionId;
    
    /** 用户ID */
    private Long userId;
    
    /** 消息类型：user-用户消息，ai-AI回复 */
    private String messageType;
    
    /** 消息内容 */
    private String content;
    
    /** 消息状态：1-正常，0-已删除 */
    private Integer status;
    
    /** 创建时间 */
    private LocalDateTime createTime;
    
    /** AI响应时间（毫秒，用于性能分析） */
    private Long responseTime;
    
    /** 扣子API的用户ID（用于会话上下文） */
    private String cozeUserId;
    
    /**
     * 构造函数（创建用户消息）
     */
    public ChatMessage(Long sessionId, Long userId, String messageType, String content, String cozeUserId) {
        this.sessionId = sessionId;
        this.userId = userId;
        this.messageType = messageType;
        this.content = content;
        this.cozeUserId = cozeUserId;
        this.status = 1; // 默认正常状态
        this.createTime = LocalDateTime.now();
    }
    
    /**
     * 构造函数（创建AI回复消息）
     */
    public ChatMessage(Long sessionId, Long userId, String content, Long responseTime, String cozeUserId) {
        this.sessionId = sessionId;
        this.userId = userId;
        this.messageType = "ai";
        this.content = content;
        this.responseTime = responseTime;
        this.cozeUserId = cozeUserId;
        this.status = 1;
        this.createTime = LocalDateTime.now();
    }
} 